<!DOCTYPE html>
<html lang="zh">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title></title>
        <style type="text/css">
            * {
                padding: 0;
                margin: 0;
            }

            /* 设置滚动条的样式 */
            ::-webkit-scrollbar {
                width: 2px;
                height: 2px;
            }

            /*滚动槽*/
            ::-webkit-scrollbar-track {
                box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1);
                border-radius: 10px;
            }

            ::-webkit-scrollbar-thumb {
                border-radius: 10px;
                background: rgba(0, 0, 0, 0.1);
                box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.15);
            }

            .table-all {
                width: 180px;
                height: 100%;
                position: relative;
            }

            .cover {
                width: 100%;
                height: 100%;
                position: absolute;
                left: 0;
                right: 0;
                z-index: 10;
            }

            .cover-time {
                position: fixed;
                left: 10px;
                top: 2%;
                font-size: 60px;
                color: #ACD290;
            }
            .warning{
                color: #fb9f8d;
            }
        </style>
    </head>
    <body>
        <div class="table-all">
           <div class="cover" id="cover">
                <div class="cover-time" id="endTime">
                   
                </div>
            </div>
            <iframe id="tabs" src="" scrolling="yes"></iframe>
        </div>

    </body>
    <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
	<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
	<script type="text/javascript" src="../../../common/service/config.service.js"></script>
    <script type="text/javascript">
		var tableData = {}
		window.onload = () => {
			getTableList()
		}
        function getQuery(name) {
			
            return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location
                .href) || [, ''])[1].replace(/\+/g, '%20')) || null
        }
        var tab = document.getElementById('tabs')
        tab.src = 'https://x.lz.wan888.club/list.html?tableId=' + getQuery('id')
        var cov = document.getElementById('cover')
        cov.onclick = () => {
            uni.redirectTo({
                url: '/pages/live/live?id=' + getQuery('id') + '&type_id=3'
            })
        }
        var endTime = document.getElementById('endTime')
		
        // var maxtime = getQuery('end_time'); //一个小时，按秒计算，自己调整!  
		var maxtime = 0; //一个小时，按秒计算，自己调整! 
		function getTableList() {
			if(maxtime > 0) {
				if (maxtime >= 0) {
					 endTime.innerHTML = maxtime;
					 if(maxtime <= 3 && maxtime >= 0){
						 endTime.classList.add("warning")
					 }else{
						 endTime.classList.remove("warning")
					 }
					 --maxtime;
				}
				if(maxtime <= 0){
					endTime.innerText='开牌中...'
					endTime.style.setProperty('font-size', '25px')
					endTime.style.color='blue'
				}
				setTimeout(() => {
					getTableList()
					
				},1000)
				return
			}
			$.ajax({
				url:"https://xapi.wan888.club/home/table/list",
				type:"post",
				headers: {
					"x-csrf-token": getQuery('token')
				},
				data:{type_id:getQuery('type_id')},
				success:function(res){
					var result = JSON.parse(res)
					if(result.code == 200) {
						tableData = result.data[getQuery('index')]
						maxtime = tableData.end_time
						
						setTimeout(() => {
							getTableList()
						},1000)
					}
				}
			});
		}
        // timer = setInterval(()=>{			
   //          if (maxtime >= 0) {
   //              endTime.innerHTML = maxtime;
   //              if(maxtime <= 3 && maxtime >= 0){
   //                  endTime.classList.add("warning")
   //              }else{
   //                  endTime.classList.remove("warning")
   //              }
   //              --maxtime;
   //          } else {
   //              clearInterval(timer);
   //          }
			// if(maxtime <= 0){
			// 	endTime.innerText='开牌中...'
			// 	endTime.style.setProperty('font-size', '25px')
			// 	endTime.style.color='blue'
			// }
   //      }, 1000)
    </script>
</html>
